const express = require('express');
const router = express.Router();

// 获取文件列表
router.get('/', (req, res) => {
  res.json({
    files: [
      { id: 1, name: 'file1.txt', size: '1KB' },
      { id: 2, name: 'file2.txt', size: '2KB' }
    ]
  });
});

// 获取单个文件信息
router.get('/:id', (req, res) => {
  res.json({
    id: req.params.id,
    name: `file${req.params.id}.txt`,
    size: '1KB',
    type: 'text/plain'
  });
});

// 上传文件
router.post('/upload', (req, res) => {
  res.status(201).json({
    message: 'File uploaded successfully',
    file: {
      id: Date.now(),
      name: req.body.name || 'unnamed.txt',
      size: req.body.size || '0KB'
    }
  });
});

// 删除文件
router.delete('/:id', (req, res) => {
  res.json({
    message: `File ${req.params.id} deleted successfully`
  });
});

module.exports = router; 